<html>
  <head>
    <style>
      table.form {
        font-size: 12px;
      }
      table.form td {
        padding: 0 10 0 0;
      }
      table.form tr.even {
        background-color: #cccccc;
      }
      table.form td.label {
        color: #15428B;
        font-weight: normal;
      }
      table.form td.label {
        color: #15428B;
      }
    </style>  
    <script>

Ext.require([
    'Ext.form.*',
    'Ext.layout.container.Column',
    'Ext.tab.Panel'
]);

Ext.onReady(function(){

    var resource = Ext.create('Ext.form.Panel', {
        url:'save-form.php',
        frame:true,
        bodyStyle:'padding:5px 5px 0',
        width: 600,
        fieldDefaults: {
          msgTarget: 'side',
          labelWidth: 200
        },
        defaultType: 'textfield',
        items: [{
          fieldLabel: 'Name',
          name: 'name',
          value: '${crawlableResource.name}',
          disabled: true
        },{
            fieldLabel: 'Owning organization',
            value: '${crawlableResource.organizationName}',
            disabled: true
        },{
            fieldLabel: 'Access point type',
            value: '${crawlableResource.type}',
            disabled: true
        },{
            fieldLabel: 'Access point',
            value: '<a href="${crawlableResource.url}">${crawlableResource.url}</a>',
            disabled: true,
            type: 'displayfield', //TODO  - how?
        },{
            fieldLabel: 'Last seen online',
            value: '<@s.date name="crawlableResource.lastSeenOnline" format="MM/dd/yyyy hh:mm:ss"/>',
            disabled: true
        },
          <#if crawlableResource.resourceCode??>
            {
                fieldLabel: 'Resource code',
                value: '${crawlableResource.resourceCode}',
                disabled: true,
            },
          </#if>
          <#if crawlableResource.contentNamespace??>
            {
                fieldLabel: 'Content namespace',
                value: '${crawlableResource.contentNamespace}',
                disabled: true,
            },
          </#if>
          <#if crawlableResource.datasetTitle??>
            {
                fieldLabel: 'Dataset title',
                value: '${crawlableResource.datasetTitle}',
                disabled: true,
            },
          </#if>
          <#if crawlableResource.schemaLocation??>
            {
                fieldLabel: 'Schema Location',
                value: '${crawlableResource.schemaLocation}',
                disabled: true,
            },
          </#if>
          {
              fieldLabel: 'Records declared',
              value: '${crawlableResource.recordsDeclared!Unknown}',
              disabled: true,
          },
          {
              fieldLabel: 'Records harvested',
              value: '${crawlableResource.recordsCrawled!Unknown}',
              disabled: true,
          },
          {
              fieldLabel: 'Records Indexed',
              value: '${crawlableResource.recordsIndexed!Unknown}',
              disabled: true,
          },
          <#if crawlableResource.recordsDeclared?? && crawlableResource.recordsCrawled??>
            {
                fieldLabel: 'Records dropped in harvesting',
                value: '${crawlableResource.recordsCrawled-crawlableResource.recordsDeclared}',
                disabled: true,
            },
          </#if>
          <#if crawlableResource.recordsIndexed?? && crawlableResource.recordsCrawled??>
            {
                fieldLabel: 'Records dropped in processing',
                value: '${crawlableResource.recordsIndexed-crawlableResource.recordsCrawled}',
                disabled: true,
            },
          </#if>
          <#if crawlableResource.recordsIndexed?? && crawlableResource.recordsDeclared??>
            {
                fieldLabel: 'Records dropped in total',
                value: '${crawlableResource.recordsIndexed-crawlableResource.recordsDeclared}',
                disabled: true,
            },
          </#if>
          {
              fieldLabel: 'Next harvest scheduled',
              value: '<@s.date name="crawlableResource.nextFireTime" var="nextFireTime" format="MM/dd/yyyy hh:mm:ss"/>',
          },
          {
              fieldLabel: 'Crawl frequency (days)',
              value: '${crawlableResource.crawlPeriodDays}',
          },
          {
              fieldLabel: 'Hide from under-harvested summary lists',
              value: '${crawlableResource.hideFromUnderCrawledList?string}',
              // TODO a checkbox
          },
          {
              fieldLabel: 'Hide from over-harvested summary lists',
              value: '${crawlableResource.hideFromOverCrawledList?string}',
              // TODO a checkbox
          },
          {
              fieldLabel: 'Hide from offline resources lists',
              value: '${crawlableResource.hideFromOfflineCrawledList?string}',
              // TODO a checkbox
          },
          {
              fieldLabel: 'Priority',
              value: '${crawlableResource.adminPriority}',
              // TODO a select
          },
        ],

        buttons: [{
            text: 'Save'
        }]
    });

    resource.render("subPage");
});

    
    </script>
  </head>
  <body>
    <div class="subMenu">
      <#include "menu.ftl">
    </div>
  
    <div class="subPage" id="subPage">
      <@s.form action="CrawlableResource/save">
        <@s.hidden name="crawlableResource.key"/>
      </@s.form>
    </div>  
  </body>
</html>